##  Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com 
##
##
##  This program is free software; you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation; either version 2 of the License, or
##  (at your option) any later version.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program; if not, write to the Free Software
##  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

import os
import sys

import VERSION

DOXY = """
DOXYFILE_ENCODING      = UTF-8


PROJECT_NAME           = "triangulum base"


PROJECT_NUMBER         = 1.0


OUTPUT_DIRECTORY       = "C:/triangulum development/triangulum_base/release/docs"


CREATE_SUBDIRS         = NO


OUTPUT_LANGUAGE        = English


BRIEF_MEMBER_DESC      = YES


REPEAT_BRIEF           = YES


ABBREVIATE_BRIEF       = "The $name class" \
                         "The $name widget" \
                         "The $name file" \
                         is \
                         provides \
                         specifies \
                         contains \
                         represents \
                         a \
                         an \
                         the


ALWAYS_DETAILED_SEC    = NO


INLINE_INHERITED_MEMB  = NO


FULL_PATH_NAMES        = NO


STRIP_FROM_PATH        = 


STRIP_FROM_INC_PATH    = 


SHORT_NAMES            = NO


JAVADOC_AUTOBRIEF      = NO


QT_AUTOBRIEF           = NO


MULTILINE_CPP_IS_BRIEF = NO


INHERIT_DOCS           = YES


SEPARATE_MEMBER_PAGES  = NO


TAB_SIZE               = 8


ALIASES                = 


OPTIMIZE_OUTPUT_FOR_C  = NO


OPTIMIZE_OUTPUT_JAVA   = NO


OPTIMIZE_FOR_FORTRAN   = NO


OPTIMIZE_OUTPUT_VHDL   = NO


EXTENSION_MAPPING      = 


BUILTIN_STL_SUPPORT    = NO


CPP_CLI_SUPPORT        = NO


SIP_SUPPORT            = NO


IDL_PROPERTY_SUPPORT   = YES


DISTRIBUTE_GROUP_DOC   = NO


SUBGROUPING            = YES


TYPEDEF_HIDES_STRUCT   = NO


SYMBOL_CACHE_SIZE      = 0



EXTRACT_ALL            = NO


EXTRACT_PRIVATE        = NO


EXTRACT_STATIC         = NO


EXTRACT_LOCAL_CLASSES  = YES


EXTRACT_LOCAL_METHODS  = NO


EXTRACT_ANON_NSPACES   = NO


HIDE_UNDOC_MEMBERS     = NO


HIDE_UNDOC_CLASSES     = NO


HIDE_FRIEND_COMPOUNDS  = NO


HIDE_IN_BODY_DOCS      = NO


INTERNAL_DOCS          = NO


CASE_SENSE_NAMES       = NO


HIDE_SCOPE_NAMES       = NO


SHOW_INCLUDE_FILES     = YES


FORCE_LOCAL_INCLUDES   = NO


INLINE_INFO            = YES


SORT_MEMBER_DOCS       = YES


SORT_BRIEF_DOCS        = NO


SORT_MEMBERS_CTORS_1ST = NO


SORT_GROUP_NAMES       = NO


SORT_BY_SCOPE_NAME     = NO


GENERATE_TODOLIST      = YES


GENERATE_TESTLIST      = YES


GENERATE_BUGLIST       = YES


GENERATE_DEPRECATEDLIST= YES


ENABLED_SECTIONS       = 


MAX_INITIALIZER_LINES  = 30


SHOW_USED_FILES        = YES


SHOW_DIRECTORIES       = NO


SHOW_FILES             = YES


SHOW_NAMESPACES        = YES


FILE_VERSION_FILTER    = 


LAYOUT_FILE            = 



QUIET                  = NO


WARNINGS               = YES


WARN_IF_UNDOCUMENTED   = YES


WARN_IF_DOC_ERROR      = YES


WARN_NO_PARAMDOC       = NO


WARN_FORMAT            = "$file:$line: $text"


WARN_LOGFILE           = 



INPUT                  = "C:/triangulum development/triangulum_base/release/include"


INPUT_ENCODING         = UTF-8


FILE_PATTERNS          = *.c \
                         *.cc \
                         *.cxx \
                         *.cpp \
                         *.c++ \
                         *.d \
                         *.java \
                         *.ii \
                         *.ixx \
                         *.ipp \
                         *.i++ \
                         *.inl \
                         *.h \
                         *.hh \
                         *.hxx \
                         *.hpp \
                         *.h++ \
                         *.idl \
                         *.odl \
                         *.cs \
                         *.php \
                         *.php3 \
                         *.inc \
                         *.m \
                         *.mm \
                         *.dox \
                         *.py \
                         *.f90 \
                         *.f \
                         *.vhd \
                         *.vhdl


RECURSIVE              = YES


EXCLUDE                = 


EXCLUDE_SYMLINKS       = NO


EXCLUDE_PATTERNS       = 


EXCLUDE_SYMBOLS        = 


EXAMPLE_PATH           = 


EXAMPLE_PATTERNS       = *


EXAMPLE_RECURSIVE      = NO


IMAGE_PATH             = 


INPUT_FILTER           = 


FILTER_PATTERNS        = 


FILTER_SOURCE_FILES    = NO



SOURCE_BROWSER         = NO


INLINE_SOURCES         = NO


STRIP_CODE_COMMENTS    = YES


REFERENCED_BY_RELATION = NO


REFERENCES_RELATION    = NO


REFERENCES_LINK_SOURCE = YES


USE_HTAGS              = NO


VERBATIM_HEADERS       = YES



ALPHABETICAL_INDEX     = NO


COLS_IN_ALPHA_INDEX    = 5


IGNORE_PREFIX          = 



GENERATE_HTML          = YES


HTML_OUTPUT            = html


HTML_FILE_EXTENSION    = .html


HTML_HEADER            = 


HTML_FOOTER            = 


HTML_STYLESHEET        = 


HTML_TIMESTAMP         = YES


HTML_ALIGN_MEMBERS     = YES


HTML_DYNAMIC_SECTIONS  = NO


GENERATE_DOCSET        = NO


DOCSET_FEEDNAME        = "Doxygen generated docs"


DOCSET_BUNDLE_ID       = org.doxygen.Project


GENERATE_HTMLHELP      = NO


CHM_FILE               = 


HHC_LOCATION           = 


GENERATE_CHI           = NO


CHM_INDEX_ENCODING     = 


BINARY_TOC             = NO


TOC_EXPAND             = NO


GENERATE_QHP           = NO


QCH_FILE               = 


QHP_NAMESPACE          = org.doxygen.Project


QHP_VIRTUAL_FOLDER     = doc


QHP_CUST_FILTER_NAME   = 


QHP_CUST_FILTER_ATTRS  = 


QHP_SECT_FILTER_ATTRS  = 


QHG_LOCATION           = 


GENERATE_ECLIPSEHELP   = NO


ECLIPSE_DOC_ID         = org.doxygen.Project


DISABLE_INDEX          = NO


ENUM_VALUES_PER_LINE   = 4


GENERATE_TREEVIEW      = YES


USE_INLINE_TREES       = NO


TREEVIEW_WIDTH         = 250


FORMULA_FONTSIZE       = 10


SEARCHENGINE           = NO


SERVER_BASED_SEARCH    = NO



GENERATE_LATEX         = NO


LATEX_OUTPUT           = latex


LATEX_CMD_NAME         = latex


MAKEINDEX_CMD_NAME     = makeindex


COMPACT_LATEX          = NO


PAPER_TYPE             = a4wide


EXTRA_PACKAGES         = 


LATEX_HEADER           = 


PDF_HYPERLINKS         = YES


USE_PDFLATEX           = YES


LATEX_BATCHMODE        = NO


LATEX_HIDE_INDICES     = NO


LATEX_SOURCE_CODE      = NO



GENERATE_RTF           = NO


RTF_OUTPUT             = rtf


COMPACT_RTF            = NO


RTF_HYPERLINKS         = NO


RTF_STYLESHEET_FILE    = 


RTF_EXTENSIONS_FILE    = 



GENERATE_MAN           = NO


MAN_OUTPUT             = man


MAN_EXTENSION          = .3


MAN_LINKS              = NO



GENERATE_XML           = NO


XML_OUTPUT             = xml


XML_SCHEMA             = 


XML_DTD                = 


XML_PROGRAMLISTING     = YES



GENERATE_AUTOGEN_DEF   = NO



GENERATE_PERLMOD       = NO


PERLMOD_LATEX          = NO


PERLMOD_PRETTY         = YES


PERLMOD_MAKEVAR_PREFIX = 



ENABLE_PREPROCESSING   = YES


MACRO_EXPANSION        = NO


EXPAND_ONLY_PREDEF     = NO


SEARCH_INCLUDES        = YES


INCLUDE_PATH           = 


INCLUDE_FILE_PATTERNS  = 


PREDEFINED             = 


EXPAND_AS_DEFINED      = 


SKIP_FUNCTION_MACROS   = YES



TAGFILES               = 


GENERATE_TAGFILE       = 


ALLEXTERNALS           = NO


EXTERNAL_GROUPS        = YES


PERL_PATH              = /usr/bin/perl



CLASS_DIAGRAMS         = YES


MSCGEN_PATH            = 


HIDE_UNDOC_RELATIONS   = YES


HAVE_DOT               = NO


DOT_FONTNAME           = FreeSans


DOT_FONTSIZE           = 10


DOT_FONTPATH           = 


CLASS_GRAPH            = YES


COLLABORATION_GRAPH    = YES


GROUP_GRAPHS           = YES


UML_LOOK               = NO


TEMPLATE_RELATIONS     = NO


INCLUDE_GRAPH          = YES


INCLUDED_BY_GRAPH      = YES


CALL_GRAPH             = NO


CALLER_GRAPH           = NO


GRAPHICAL_HIERARCHY    = YES


DIRECTORY_GRAPH        = YES


DOT_IMAGE_FORMAT       = png


DOT_PATH               = 


DOTFILE_DIRS           = 


DOT_GRAPH_MAX_NODES    = 50


MAX_DOT_GRAPH_DEPTH    = 0


DOT_TRANSPARENT        = NO


DOT_MULTI_TARGETS      = NO


GENERATE_LEGEND        = YES


DOT_CLEANUP            = YES

"""

#=============================================

def getDoc(projName = '',version = '',inputDir = '',outputDir = '',recursive = False):
   lines = DOXY.split('\n')
   ret =''
   try:
      os.mkdir(outputDir)
   except:
      pass
   for l in lines:
      if l.startswith('PROJECT_NAME'):
         ret+= 'PROJECT_NAME           =\"'+projName+"\"\n"
      elif l.startswith('PROJECT_NUMBER'):
         ret+= 'PROJECT_NUMBER         ='+version+"\n"
      elif l.startswith('OUTPUT_DIRECTORY'):
         ret+= 'OUTPUT_DIRECTORY       =\"'+outputDir+"\"\n"
      elif l.startswith('INPUT '):
         ret+= 'INPUT                  =\"'+inputDir+"\"\n"
      elif l.startswith('RECURSIVE'):
         rec = "FALSE"
         if recursive:
            rec = 'TRUE'
         ret+= 'RECURSIVE              =\"'+rec+"\"\n"
         
      else:
         ret+=l+'\n'
   return ret
      
def main():
   doc_base =  getDoc(VERSION.getProject(),VERSION.getVersion(),os.path.join(os.getcwd(),'release','include','base'),os.path.join(os.getcwd(),'release','docs','base'))
   doc =  getDoc(VERSION.getProject(),VERSION.getVersion(),os.path.join(os.getcwd(),'release','include'),os.path.join(os.getcwd(),'release','docs'))
   doc_ext =  getDoc(VERSION.getProject(),VERSION.getVersion(),os.path.join(os.getcwd(),'release','include','ext'),os.path.join(os.getcwd(),'release','docs','ext'))
   doc_phy =  getDoc(VERSION.getProject(),VERSION.getVersion(),os.path.join(os.getcwd(),'release','include','physics'),os.path.join(os.getcwd(),'release','docs','physics'))

   fh2 = open('Doxyfile_Base','w')
   fh2.write(doc_base)
   fh2.close()

   fh2 = open('Doxyfile','w')
   fh2.write(doc)
   fh2.close()

   fh2 = open('Doxyfile_Ext','w')
   fh2.write(doc_ext)
   fh2.close()

   fh2 = open('Doxyfile_Physics','w')
   fh2.write(doc_phy)
   fh2.close()

#=============================================

if __name__ == '__main__':
    main()
